﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes {
    import flash.geom.*;
    import Engine.Helpers.*;
    import Engine.*;

    public class IsoRect {

        public static var TILE_HEIGHT:Number = 16;
        public static var TILE_SIZE:Number = 4;

        private var _left:Point;
        private var _right:Point;
        private var _top:Point;
        private var _bottom:Point;
        private var _width:Number = 0;
        private var _height:Number = 0;

        public function IsoRect(_arg1:Point=null, _arg2:Point=null, _arg3:Point=null, _arg4:Point=null){
            this._left = _arg1;
            this._right = _arg2;
            this._top = _arg3;
            this._bottom = _arg4;
            this.setWidth();
            this.setHeight();
        }
        public static function getIsoRectFromSize(_arg1:Vector3):IsoRect{
            var _local2:Point = tilePosToPixelPos(0, 0);
            var _local3:Point = tilePosToPixelPos((_arg1.x * TILE_SIZE), (-(_arg1.y) * TILE_SIZE));
            var _local4:Point = tilePosToPixelPos((_arg1.x * TILE_SIZE), 0);
            var _local5:Point = tilePosToPixelPos(0, (-(_arg1.y) * TILE_SIZE));
            var _local6:IsoRect = new IsoRect(_local2, _local3, _local4, _local5);
            return (_local6);
        }
        public static function tilePosToPixelPos(_arg1:Number, _arg2:Number, _arg3:Number=0):Vector2{
            var _local4:Number;
            var _local5:Number;
            var _local6:Vector2 = new Vector2((Constants.TILE_WIDTH / 2), Constants.TILE_HEIGHT);
            var _local7:Object = IsoMath.DIRECTION_VECTORS[Constants.ROTATION_0];
            _local4 = (((_local7.x.x * _arg1) + (_local7.y.x * _arg2)) * (Constants.TILE_WIDTH / 2));
            _local5 = (((_local7.x.y * _arg1) + (_local7.y.y * _arg2)) * (Constants.TILE_HEIGHT / 2));
            _local5 = (_local5 + (_arg3 * TILE_HEIGHT));
            return (new Vector2(_local4, _local5));
        }

        public function get left():Point{
            return (this._left);
        }
        public function set left(_arg1:Point):void{
            this._left = _arg1;
            this.setWidth();
        }
        public function get right():Point{
            return (this._right);
        }
        public function set right(_arg1:Point):void{
            this._right = _arg1;
            this.setWidth();
        }
        public function get top():Point{
            return (this._top);
        }
        public function set top(_arg1:Point):void{
            this._top = _arg1;
            this.setHeight();
        }
        public function get bottom():Point{
            return (this._bottom);
        }
        public function set bottom(_arg1:Point):void{
            this._bottom = _arg1;
            this.setHeight();
        }
        public function get width():Number{
            return (this._width);
        }
        private function setWidth():void{
            this._width = (((this._right) && (this._left))) ? (this._right.x - this._left.x) : 0;
        }
        public function get height():Number{
            return (this._height);
        }
        private function setHeight():void{
            this._height = (((this._bottom) && (this._top))) ? (this._bottom.y - this._top.y) : 0;
        }

    }
}//package Classes 
